import unittest
from time import sleep

from common.functions import save_screenshot
from common.decorators import mkdir_classname, log4gs
from common.settings import TAG
from pages_example.gridDataManagePage import GridDataManagePage


@log4gs
@mkdir_classname(TAG)
class MacManageTest(unittest.TestCase):
    """网格管理功能测试"""
    @classmethod
    def setUpClass(cls):
        cls.log.info('=' * 30 + "开始网格管理功能测试({})".format(__class__.__name__) + '=' * 30)
        cls.page = GridDataManagePage('/DataManage/GridDataManage')

    @classmethod
    def tearDownClass(cls):
        cls.log.info('=' * 30 + "结束网格管理功能测试({})".format(__class__.__name__) + '=' * 30)
        cls.page.driver.quit()

    def setUp(self):
        self.log.info('>>>>>开始执行用例：{} {}'.format(self.id(), self.shortDescription()))

    def tearDown(self):
        self.log.info('<<<<<结束执行用例：{} {}'.format(self.id(), self.shortDescription()))

    @unittest.skip
    def test_abc1(self):
        """举例：网格管理5级区域选择器"""
        sleep(1)
        self.page.table.add_btn.click()
        sleep(2)
        self.page.add_grid.region.click()
        sleep(1)
        # self.page.add_grid.region_selector.select("云南省-玉溪市-澄江县-右所镇-小西村民委员会")
        # self.page.add_grid.region_selector.select("广西壮族自治区-南宁市-青秀区-中山街道-中山社区")
        self.page.add_grid.region_selector.select("广东省-广州市-白云区")
        sleep(3)

    @unittest.skip
    def test_abc2(self):
        """举例：往textarea里面写数据"""
        sleep(5)
        self.page.table.add_btn.click()
        sleep(1)
        self.page.add_grid.grid_area.send_keys('fewrgegwet4hg4qhq')
        sleep(5)

    def test_abc3(self):
        """举例：点击地图获取经纬度"""
        sleep(5)
        self.page.table.add_btn.click()
        sleep(1)
        self.page.add_grid.map.click()
        sleep(3)



if __name__ == '__main__':
    unittest.main()